//当前这个模块：API进行统一管理
import requests from "./request";
import mockRequests from './mockAjax'


//三级联动接口
///api.product/getBaseCategoryList get 无参
 
//发送请求:axios发请求返回结果是Promise对象
export const reqCategoryList = ()=>{
    console.log("我发了请求(typenav)");
    return requests({
        url:'/api/product/getBaseCategoryList',
        method:'get'
    })
}

//获取轮播图banners
export const reqGetBannerList = ()=>{
    console.log('我发了mock请求(banners)');
    return mockRequests({
        url:'banners',
        method:'get'
    })
}
//获取轮播图floors
export const reqGetFloorList = ()=>{
    console.log('我发了mock请求(floor)');
    return mockRequests({
        url:'floors',
        method:'get'
    })
}
//获取search内容
export const reqGetSearchList = (params)=>{
    console.log('我发了请求(search)');
    return requests({
        url:'api/list',
        method:'post',
        data:params
    })
}
//获取detail的内容
export const reqGetGoodInfo = (params)=>{
    console.log('我发了请求(detail)');
    return requests({
        url:`api/item/${params}`,
        method:'get',
        data:params
    })
}
//添加到购物车
export const reqAddToCart = (skuId,skuNum)=>{
    console.log('我发了请求(addtocart)');
    return requests({
        url:`api/cart/addToCart/${skuId}/${skuNum}`,
        method:'post',
        data:skuId,skuNum
    })
}
//去购物车结算
export const reqShopCart = ()=>{
    console.log('我发了请求(shopcart)');
    return requests({
        url:'api/cart/cartList',
        method:'get'
    })
}
//删除商品
export const reqDelCart = (skuId)=>{
    console.log('我发了请求(delcart)');
    return requests({
        url:`api/cart/deleteCart/${skuId}`,
        method:'delete'
    })
}
//切换商品选中状态
/* 
    /api/cart/checkCart/{skuID}/{isChecked} 
*/
export const reqCheckCart = (skuId,isChecked)=>{
    console.log('我发了请求(CheckCart)');
    return requests({
        url:`api/cart/checkCart/${skuId}/${isChecked}`,
        method:'get'
    })
}
//获取验证码
export const reqGetCode = (phone)=>{
    console.log('我发了请求(getcode)');
    return requests({
        url:`/api/user/passport/sendCode/${phone}`,
        method:'get'
    })
}
//用户注册
export const reqUserRegister = (data)=>{
    console.log('我发了请求(userregister)');
    return requests({
        url:'api/user/passport/register',
        data,
        method:'post'
    })
}
//用户登录
export const reqUserLogin = (data)=>{
    console.log('我发了请求(userlogin)');
    return requests({
        url:'api/user/passport/login',
        data,
        method:'post'
    })
}
//获取用户信息
export const reqGetUserInfo = (data)=>{
    console.log('我发了请求(getuserinfo)');
    return requests({
        url:'api/user/passport/auth/getUserInfo',
        data,
        method:'get'
    })
}
//用户退出登录
export const reqLoginOut = (data)=>{
    console.log('我发了请求(loginout)');
    return requests({
        url:'api/user/passport/logout',
        data,
        method:'get'
    })
}
//购物车点击结算，用户获取订单页信息
// /api/order/auth/trade
export const reqGetTrade = ()=>{
    console.log('我发了请求(gettrade)');
    return requests({
        url:'api/order/auth/trade',
        method:'get'
    })
}
//提交订单
// /api/order/auth/submitOrder?tradeNo={tradeNo}
export const reqSubmitOrder = (tradeNo,data)=>{
    console.log('我发了请求(submitOrder)');
    return requests({
        url:`api/order/auth/submitOrder?tradeNo=${tradeNo}`,
        data:tradeNo,data,
        method:'post'
    })
}
//提交订单成功，获取支付信息
// /api/payment/weixin/createNative/{orderId}
export const reqPayment = (orderId)=>{
    console.log('我发了请求(payment)');
    return requests({
        url:`api/payment/weixin/createNative/${orderId}`,
        method:'get'
    })
}
//获取支付订单状态
// /api/payment/weixin/queryPayStatus/{orderId}
export const reqPayStatus = (orderId)=>{
    console.log('我发了请求(paystatus)');
    return requests({
        url:`api/payment/weixin/queryPayStatus/${orderId}`,
        method:'get'
    })
}
//获取我的订单列表
// /api/order/auth/{page}/{limit}
// page:页码  limit:每页显示的数量
export const reqGetOrder = (page,limit)=>{
    console.log('我发了请求(getorder)');
    return requests({
        url:`api/order/auth/${page}/${limit}`,
        method:'get'
    })
}